﻿using System.Windows;
using System.Windows.Controls;
using System.Windows.Input;
using corpus_platform.ViewModels;

namespace corpus_platform.Views.Control
{
    /// <summary>
    /// Interaction logic for OntologyNode
    /// </summary>
    public partial class OntologyNode : UserControl
    {
        public OntologyNode()
        {
            InitializeComponent();
        }

        protected override void OnMouseDown(MouseButtonEventArgs e)
        {
            base.OnMouseDown(e);
            FrameworkElement element = (FrameworkElement)e.Source;
            OntologyViewModel ontology = (OntologyViewModel)element.DataContext;

            if (ontology.AllowDrag)
            {
                DataObject dataObject = new();
                dataObject.SetData("Node", ontology);
                DragDrop.DoDragDrop(this, dataObject, DragDropEffects.Move);
            }
            e.Handled = true;
        }
    }
}
